<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/avatar100.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/avatar100.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/avatar30.png">
  <link rel="mask-icon" href="/images/avatar100.png" color="#222">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"fengwenyi.gitee.io","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":"valine","storage":true,"lazyload":false,"nav":null,"activeClass":"valine"},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":true,"preload":true},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="很久很久……以前，我们开始了vue-admin-pro之旅。通过 后端管理系统开发（一）：登录篇 ，实现登录功能，我们打开了后台管理系统的大门。本节是路由篇的讲解，不管管理系统如何简单，都少不了路由，所以，学习这一节，很有必要。不过呢，对于我们来说，路由就是菜单。">
<meta property="og:type" content="article">
<meta property="og:title" content="后端管理系统开发（二）：路由篇">
<meta property="og:url" content="https://fengwenyi.gitee.io/2021/04/14/vue-admin-pro-02/index.html">
<meta property="og:site_name" content="冯文议博客">
<meta property="og:description" content="很久很久……以前，我们开始了vue-admin-pro之旅。通过 后端管理系统开发（一）：登录篇 ，实现登录功能，我们打开了后台管理系统的大门。本节是路由篇的讲解，不管管理系统如何简单，都少不了路由，所以，学习这一节，很有必要。不过呢，对于我们来说，路由就是菜单。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fengwenyi.gitee.io/2021/04/14/vue-admin-pro-02/20210412212416.png">
<meta property="og:image" content="https://fengwenyi.gitee.io/2021/04/14/vue-admin-pro-02/20210412212513.png">
<meta property="article:published_time" content="2021-04-14T13:36:39.000Z">
<meta property="article:modified_time" content="2021-04-14T13:42:15.772Z">
<meta property="article:author" content="Erwin Feng">
<meta property="article:tag" content="vue.js">
<meta property="article:tag" content="vue-admin-pro">
<meta property="article:tag" content="View UI">
<meta property="article:tag" content="iview-admin">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fengwenyi.gitee.io/2021/04/14/vue-admin-pro-02/20210412212416.png">

<link rel="canonical" href="https://fengwenyi.gitee.io/2021/04/14/vue-admin-pro-02/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>后端管理系统开发（二）：路由篇 | 冯文议博客</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">冯文议博客</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">专注于程序设计与开发</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">12</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">3</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">7</span></a>

  </li>
        <li class="menu-item menu-item-links">

    <a href="/links/" rel="section"><i class="fa fa-link fa-fw"></i>友链</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

  <a href="https://github.com/fengwenyi" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://fengwenyi.gitee.io/2021/04/14/vue-admin-pro-02/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="https://portrait.gitee.com/uploads/avatars/user/382/1147388_fengwenyi_1589149473.png">
      <meta itemprop="name" content="Erwin Feng">
      <meta itemprop="description" content="我是冯文议，软件开发工程师，专注于程序设计与开发。开源项目：JavaLib、api-result。喜欢看电影、听音乐、自驾游。">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="冯文议博客">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          后端管理系统开发（二）：路由篇
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-04-14 21:36:39 / 修改时间：21:42:15" itemprop="dateCreated datePublished" datetime="2021-04-14T21:36:39+08:00">2021-04-14</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/vue-admin-pro/" itemprop="url" rel="index"><span itemprop="name">vue-admin-pro</span></a>
                </span>
            </span>

          
            <span id="/2021/04/14/vue-admin-pro-02/" class="post-meta-item leancloud_visitors" data-flag-title="后端管理系统开发（二）：路由篇" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021/04/14/vue-admin-pro-02/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021/04/14/vue-admin-pro-02/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>很久很久……以前，我们开始了vue-admin-pro之旅。通过 <a href="https://fengwenyi.gitee.io/2021/04/14/vue-admin-pro-01/">后端管理系统开发（一）：登录篇</a> ，实现登录功能，我们打开了后台管理系统的大门。本节是路由篇的讲解，不管管理系统如何简单，都少不了路由，所以，学习这一节，很有必要。不过呢，对于我们来说，路由就是菜单。</p>
<span id="more"></span>

<p>下面开始我们本节——路由篇的学习之旅。</p>
<h2 id="1-基础"><a href="#1-基础" class="headerlink" title="1 基础"></a>1 基础</h2><p>读这篇文章的，我相信大多数都是后端开发人员，可能有些学过Vue，也可能没有，所以在之前，我们先一起学习下路由相关的知识。</p>
<p>如果你想了解更多，看：<a target="_blank" rel="noopener" href="https://router.vuejs.org/zh/">Vue Router </a> 。</p>
<h3 id="1-1-路由"><a href="#1-1-路由" class="headerlink" title="1.1 路由"></a>1.1 路由</h3><p>路由就是跳转。</p>
<p>声明式：<code>&lt;router-link :to=&quot;...&quot;&gt;</code></p>
<p>编程式：<code>router.push(...)</code></p>
<h3 id="1-2-router-push"><a href="#1-2-router-push" class="headerlink" title="1.2 router.push"></a>1.2 router.push</h3><p>如下示例：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 字符串</span></span><br><span class="line">router.push(<span class="string">&#x27;home&#x27;</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">// 对象</span></span><br><span class="line">router.push(&#123; <span class="attr">path</span>: <span class="string">&#x27;home&#x27;</span> &#125;)</span><br><span class="line"></span><br><span class="line"><span class="comment">// 命名的路由</span></span><br><span class="line">router.push(&#123; <span class="attr">name</span>: <span class="string">&#x27;user&#x27;</span>, <span class="attr">params</span>: &#123; <span class="attr">userId</span>: <span class="string">&#x27;123&#x27;</span> &#125;&#125;)</span><br><span class="line">router.push(&#123; <span class="attr">path</span>: <span class="string">`/user/<span class="subst">$&#123;userId&#125;</span>`</span> &#125;) <span class="comment">// -&gt; /user/123</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// 带查询参数，变成 /register?plan=private</span></span><br><span class="line">router.push(&#123; <span class="attr">path</span>: <span class="string">&#x27;register&#x27;</span>, <span class="attr">query</span>: &#123; <span class="attr">plan</span>: <span class="string">&#x27;private&#x27;</span> &#125;&#125;)</span><br></pre></td></tr></table></figure>



<p><code>router.replace</code> 不会向 history 添加新记录 = <code>&lt;router-link :to=&quot;...&quot; replace&gt;</code></p>
<h3 id="1-3-router-go-n"><a href="#1-3-router-go-n" class="headerlink" title="1.3 router.go(n)"></a>1.3 router.go(n)</h3><p>后退多少步，等于 <code>window.history.go(n)</code></p>
<p>如下示例：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 在浏览器记录中前进一步，等同于 history.forward()</span></span><br><span class="line">router.go(<span class="number">1</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">// 后退一步记录，等同于 history.back()</span></span><br><span class="line">router.go(-<span class="number">1</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">// 前进 3 步记录</span></span><br><span class="line">router.go(<span class="number">3</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">// 如果 history 记录不够用，那就默默地失败呗</span></span><br><span class="line">router.go(-<span class="number">100</span>)</span><br><span class="line">router.go(<span class="number">100</span>)</span><br></pre></td></tr></table></figure>



<h3 id="1-4-命名路由"><a href="#1-4-命名路由" class="headerlink" title="1.4 命名路由"></a>1.4 命名路由</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">router.push(&#123; <span class="attr">name</span>: <span class="string">&#x27;user&#x27;</span>, <span class="attr">params</span>: &#123; <span class="attr">userId</span>: <span class="number">123</span> &#125; &#125;)</span><br></pre></td></tr></table></figure>



<h3 id="1-5-重定向"><a href="#1-5-重定向" class="headerlink" title="1.5 重定向"></a>1.5 重定向</h3><p>重定向也是通过 <code>routes</code> 配置来完成，下面例子是从 <code>/a</code> 重定向到 <code>/b</code>：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> router = <span class="keyword">new</span> VueRouter(&#123;</span><br><span class="line">  routes: [</span><br><span class="line">    &#123; <span class="attr">path</span>: <span class="string">&#x27;/a&#x27;</span>, <span class="attr">redirect</span>: <span class="string">&#x27;/b&#x27;</span> &#125;</span><br><span class="line">  ]</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>

<p>重定向的目标也可以是一个命名的路由：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> router = <span class="keyword">new</span> VueRouter(&#123;</span><br><span class="line">  routes: [</span><br><span class="line">    &#123; <span class="attr">path</span>: <span class="string">&#x27;/a&#x27;</span>, <span class="attr">redirect</span>: &#123; <span class="attr">name</span>: <span class="string">&#x27;foo&#x27;</span> &#125;&#125;</span><br><span class="line">  ]</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>

<p>甚至是一个方法，动态返回重定向目标：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> router = <span class="keyword">new</span> VueRouter(&#123;</span><br><span class="line">  routes: [</span><br><span class="line">    &#123; <span class="attr">path</span>: <span class="string">&#x27;/a&#x27;</span>, <span class="attr">redirect</span>: <span class="function"><span class="params">to</span> =&gt;</span> &#123;</span><br><span class="line">      <span class="comment">// 方法接收 目标路由 作为参数</span></span><br><span class="line">      <span class="comment">// return 重定向的 字符串路径/路径对象</span></span><br><span class="line">    &#125;&#125;</span><br><span class="line">  ]</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>

<p>注意<a target="_blank" rel="noopener" href="https://router.vuejs.org/zh/guide/advanced/navigation-guards.html">导航守卫</a>并没有应用在跳转路由上，而仅仅应用在其目标上。在下面这个例子中，为 <code>/a</code> 路由添加一个 <code>beforeEnter</code> 守卫并不会有任何效果。</p>
<p>别名：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> router = <span class="keyword">new</span> VueRouter(&#123;</span><br><span class="line">  routes: [</span><br><span class="line">    &#123; <span class="attr">path</span>: <span class="string">&#x27;/a&#x27;</span>, <span class="attr">component</span>: A, <span class="attr">alias</span>: <span class="string">&#x27;/b&#x27;</span> &#125;</span><br><span class="line">  ]</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>





<h3 id="1-6-路由传参"><a href="#1-6-路由传参" class="headerlink" title="1.6 路由传参"></a>1.6 路由传参</h3><h4 id="1-6-1-通过path传参"><a href="#1-6-1-通过path传参" class="headerlink" title="1.6.1 通过path传参"></a>1.6.1 通过path传参</h4><p>参数会显示在URL上，页面刷新，数据不会丢失。</p>
<p><strong>路由配置</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  path: <span class="string">&#x27;/particulars/:id&#x27;</span>,</span><br><span class="line">  name: <span class="string">&#x27;particulars&#x27;</span>,</span><br><span class="line">  component: particulars</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<p><strong>传递参数</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//直接调用$router.push 实现携带参数的跳转</span></span><br><span class="line"><span class="built_in">this</span>.$router.push(&#123;</span><br><span class="line">  path: <span class="string">`/particulars/<span class="subst">$&#123;id&#125;</span>`</span>,</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>



<p><strong>接收参数</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">this</span>.$route.params.id</span><br></pre></td></tr></table></figure>





<h4 id="1-6-2-通过params传参"><a href="#1-6-2-通过params传参" class="headerlink" title="1.6.2 通过params传参"></a>1.6.2 通过params传参</h4><p>参数不会显示在URL上</p>
<p>页面刷新，数据会丢失</p>
<p><strong>路由配置</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  path: <span class="string">&#x27;/particulars&#x27;</span>,</span><br><span class="line">  name: <span class="string">&#x27;particulars&#x27;</span>,</span><br><span class="line">  component: particulars</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<p><strong>传递参数</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">this</span>.$router.push(&#123;</span><br><span class="line">  name: <span class="string">&#x27;particulars&#x27;</span>,</span><br><span class="line">  params: &#123;</span><br><span class="line">    id: id</span><br><span class="line">  &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>



<p><strong>接收参数</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">this</span>.$route.params.id</span><br></pre></td></tr></table></figure>



<h4 id="1-6-3-通过query传参"><a href="#1-6-3-通过query传参" class="headerlink" title="1.6.3 通过query传参"></a>1.6.3 通过query传参</h4><p>使用path来匹配路由，然后通过query来传递参数<br>这种情况下 query传递的参数会显示在url后面?id=？</p>
<p><strong>路由配置</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  path: <span class="string">&#x27;/particulars&#x27;</span>,</span><br><span class="line">  name: <span class="string">&#x27;particulars&#x27;</span>,</span><br><span class="line">  component: particulars</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<p><strong>传递参数</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">this</span>.$router.push(&#123;</span><br><span class="line">  path: <span class="string">&#x27;/particulars&#x27;</span>,</span><br><span class="line">  query: &#123;</span><br><span class="line">    id: id</span><br><span class="line">  &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>



<p><strong>接收参数</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">this</span>.$route.query.id</span><br></pre></td></tr></table></figure>







<h3 id="1-7-完整导航解析流程"><a href="#1-7-完整导航解析流程" class="headerlink" title="1.7 完整导航解析流程"></a>1.7 完整导航解析流程</h3><ol>
<li>导航被触发。</li>
<li>在失活的组件里调用 <code>beforeRouteLeave</code> 守卫。</li>
<li>调用全局的 <code>beforeEach</code> 守卫。</li>
<li>在重用的组件里调用 <code>beforeRouteUpdate</code> 守卫 (2.2+)。</li>
<li>在路由配置里调用 <code>beforeEnter</code>。</li>
<li>解析异步路由组件。</li>
<li>在被激活的组件里调用 <code>beforeRouteEnter</code>。</li>
<li>调用全局的 <code>beforeResolve</code> 守卫 (2.5+)。</li>
<li>导航被确认。</li>
<li>调用全局的 <code>afterEach</code> 钩子。</li>
<li>触发 DOM 更新。</li>
<li>调用 <code>beforeRouteEnter</code> 守卫中传给 <code>next</code> 的回调函数，创建好的组件实例会作为回调函数的参数传入。</li>
</ol>
<h2 id="2-目录结构"><a href="#2-目录结构" class="headerlink" title="2 目录结构"></a>2 目录结构</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">.</span><br><span class="line">└── src</span><br><span class="line">    └── router              	&#x2F;&#x2F; 路由目录</span><br><span class="line">        ├── before-close.js     &#x2F;&#x2F; 页面关闭前需要做的操作，写在这里</span><br><span class="line">        ├── index.js        	&#x2F;&#x2F; 路由策略</span><br><span class="line">        └── routers.js      	&#x2F;&#x2F; 路由配置</span><br></pre></td></tr></table></figure>







<h2 id="3-标签"><a href="#3-标签" class="headerlink" title="3 标签"></a>3 标签</h2><h3 id="path"><a href="#path" class="headerlink" title="path"></a>path</h3><p>路劲</p>
<h3 id="name"><a href="#name" class="headerlink" title="name"></a>name</h3><p>名字</p>
<h3 id="meta"><a href="#meta" class="headerlink" title="meta"></a>meta</h3><p>页面信息配置，这是一个对象</p>
<h3 id="title"><a href="#title" class="headerlink" title="title"></a>title</h3><p>标题</p>
<h3 id="hideInMenu"><a href="#hideInMenu" class="headerlink" title="hideInMenu"></a>hideInMenu</h3><p>是否在菜单中隐藏，布尔类型，true：隐藏；false：显示。默认：显示。</p>
<h3 id="component"><a href="#component" class="headerlink" title="component"></a>component</h3><p>组件</p>
<h3 id="notCache"><a href="#notCache" class="headerlink" title="notCache"></a>notCache</h3><p>不要缓存</p>
<h3 id="icon"><a href="#icon" class="headerlink" title="icon"></a>icon</h3><p>图标</p>
<h3 id="hideInBread"><a href="#hideInBread" class="headerlink" title="hideInBread"></a>hideInBread</h3><p>设为true后此级路由将不会出现在面包屑中</p>
<h3 id="redirect"><a href="#redirect" class="headerlink" title="redirect"></a>redirect</h3><p>跳转</p>
<h2 id="4-图标"><a href="#4-图标" class="headerlink" title="4 图标"></a>4 图标</h2><p>你可以去 <a target="_blank" rel="noopener" href="http://v1.iviewui.com/components/icon">这里</a> 筛选想要的图标</p>
<p>如果无法满足我们的需求，可以自定义图标。</p>
<p>自定义图标，需要在图标名称前加下划线 <code>_</code> 。</p>
<p>后面会用一个篇章，单独说自定义图标。</p>
<h2 id="5-多语言"><a href="#5-多语言" class="headerlink" title="5 多语言"></a>5 多语言</h2><p>如果你的系统要支持多语言，首先你要开启多语言。</p>
<p>1：将 <code>./src/config/index.js</code>  配置文件中的多语言支持开启：  <code>useI18n=true</code> 。</p>
<p>2：多语言文件在 <code>./src/local</code> 目录下。</p>
<h2 id="6-单独页"><a href="#6-单独页" class="headerlink" title="6 单独页"></a>6 单独页</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> [</span><br><span class="line">  &#123;</span><br><span class="line">    path: <span class="string">&#x27;/login&#x27;</span>,</span><br><span class="line">    name: <span class="string">&#x27;login&#x27;</span>,</span><br><span class="line">    meta: &#123;</span><br><span class="line">      title: <span class="string">&#x27;Login - 登录&#x27;</span>,</span><br><span class="line">      hideInMenu: <span class="literal">true</span></span><br><span class="line">    &#125;,</span><br><span class="line">    component: <span class="function">() =&gt;</span> <span class="keyword">import</span>(<span class="string">&#x27;@/view/Login/Login&#x27;</span>)</span><br><span class="line">  &#125;</span><br><span class="line">]</span><br></pre></td></tr></table></figure>







<h2 id="7-一级菜单"><a href="#7-一级菜单" class="headerlink" title="7 一级菜单"></a>7 一级菜单</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> [</span><br><span class="line">  &#123;</span><br><span class="line">    path: <span class="string">&#x27;/tools_methods&#x27;</span>,</span><br><span class="line">    name: <span class="string">&#x27;tools_methods&#x27;</span>,</span><br><span class="line">    meta: &#123;</span><br><span class="line">      hideInBread: <span class="literal">true</span></span><br><span class="line">    &#125;,</span><br><span class="line">    component: Main,</span><br><span class="line">    children: [</span><br><span class="line">      &#123;</span><br><span class="line">        path: <span class="string">&#x27;tools_methods_page&#x27;</span>,</span><br><span class="line">        name: <span class="string">&#x27;tools_methods_page&#x27;</span>,</span><br><span class="line">        meta: &#123;</span><br><span class="line">          icon: <span class="string">&#x27;ios-hammer&#x27;</span>,</span><br><span class="line">          title: <span class="string">&#x27;工具方法&#x27;</span>,</span><br><span class="line">          beforeCloseName: <span class="string">&#x27;before_close_normal&#x27;</span></span><br><span class="line">        &#125;,</span><br><span class="line">        component: <span class="function">() =&gt;</span> <span class="keyword">import</span>(<span class="string">&#x27;@/view/tools-methods/tools-methods.vue&#x27;</span>)</span><br><span class="line">      &#125;</span><br><span class="line">    ]</span><br><span class="line">  &#125;,</span><br><span class="line">]</span><br></pre></td></tr></table></figure>







<h2 id="8-二级菜单"><a href="#8-二级菜单" class="headerlink" title="8 二级菜单"></a>8 二级菜单</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> [</span><br><span class="line">  &#123;</span><br><span class="line">    path: <span class="string">&#x27;/components&#x27;</span>,</span><br><span class="line">    name: <span class="string">&#x27;components&#x27;</span>,</span><br><span class="line">    meta: &#123;</span><br><span class="line">      icon: <span class="string">&#x27;logo-buffer&#x27;</span>,</span><br><span class="line">      title: <span class="string">&#x27;组件&#x27;</span></span><br><span class="line">    &#125;,</span><br><span class="line">    component: Main,</span><br><span class="line">    children: [</span><br><span class="line">      &#123;</span><br><span class="line">        path: <span class="string">&#x27;tree_select_page&#x27;</span>,</span><br><span class="line">        name: <span class="string">&#x27;tree_select_page&#x27;</span>,</span><br><span class="line">        meta: &#123;</span><br><span class="line">          icon: <span class="string">&#x27;md-arrow-dropdown-circle&#x27;</span>,</span><br><span class="line">          title: <span class="string">&#x27;树状下拉选择器&#x27;</span></span><br><span class="line">        &#125;,</span><br><span class="line">        component: <span class="function">() =&gt;</span> <span class="keyword">import</span>(<span class="string">&#x27;@/view/components/tree-select/index.vue&#x27;</span>)</span><br><span class="line">      &#125;,</span><br><span class="line">      &#123;</span><br><span class="line">        path: <span class="string">&#x27;count_to_page&#x27;</span>,</span><br><span class="line">        name: <span class="string">&#x27;count_to_page&#x27;</span>,</span><br><span class="line">        meta: &#123;</span><br><span class="line">          icon: <span class="string">&#x27;md-trending-up&#x27;</span>,</span><br><span class="line">          title: <span class="string">&#x27;数字渐变&#x27;</span></span><br><span class="line">        &#125;,</span><br><span class="line">        component: <span class="function">() =&gt;</span> <span class="keyword">import</span>(<span class="string">&#x27;@/view/components/count-to/count-to.vue&#x27;</span>)</span><br><span class="line">      &#125;</span><br><span class="line">    ]</span><br><span class="line">  &#125;</span><br><span class="line">]</span><br></pre></td></tr></table></figure>



<p>效果示例：</p>
<p><img src="/2021/04/14/vue-admin-pro-02/20210412212416.png" alt="二级菜单-效果示例"></p>
<h2 id="9-多级菜单"><a href="#9-多级菜单" class="headerlink" title="9 多级菜单"></a>9 多级菜单</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> [</span><br><span class="line">  &#123;</span><br><span class="line">    path: <span class="string">&#x27;/multilevel&#x27;</span>,</span><br><span class="line">    name: <span class="string">&#x27;multilevel&#x27;</span>,</span><br><span class="line">    meta: &#123;</span><br><span class="line">      icon: <span class="string">&#x27;md-menu&#x27;</span>,</span><br><span class="line">      title: <span class="string">&#x27;多级菜单&#x27;</span></span><br><span class="line">    &#125;,</span><br><span class="line">    component: Main,</span><br><span class="line">    children: [</span><br><span class="line">      &#123;</span><br><span class="line">        path: <span class="string">&#x27;level_2_1&#x27;</span>,</span><br><span class="line">        name: <span class="string">&#x27;level_2_1&#x27;</span>,</span><br><span class="line">        meta: &#123;</span><br><span class="line">          icon: <span class="string">&#x27;md-funnel&#x27;</span>,</span><br><span class="line">          title: <span class="string">&#x27;二级-1&#x27;</span></span><br><span class="line">        &#125;,</span><br><span class="line">        component: <span class="function">() =&gt;</span> <span class="keyword">import</span>(<span class="string">&#x27;@/view/multilevel/level-2-1.vue&#x27;</span>)</span><br><span class="line">      &#125;,</span><br><span class="line">      &#123;</span><br><span class="line">        path: <span class="string">&#x27;level_2_2&#x27;</span>,</span><br><span class="line">        name: <span class="string">&#x27;level_2_2&#x27;</span>,</span><br><span class="line">        meta: &#123;</span><br><span class="line">          access: [<span class="string">&#x27;super_admin&#x27;</span>],</span><br><span class="line">          icon: <span class="string">&#x27;md-funnel&#x27;</span>,</span><br><span class="line">          showAlways: <span class="literal">true</span>,</span><br><span class="line">          title: <span class="string">&#x27;二级-2&#x27;</span></span><br><span class="line">        &#125;,</span><br><span class="line">        component: parentView,</span><br><span class="line">        children: [</span><br><span class="line">          &#123;</span><br><span class="line">            path: <span class="string">&#x27;level_2_2_1&#x27;</span>,</span><br><span class="line">            name: <span class="string">&#x27;level_2_2_1&#x27;</span>,</span><br><span class="line">            meta: &#123;</span><br><span class="line">              icon: <span class="string">&#x27;md-funnel&#x27;</span>,</span><br><span class="line">              title: <span class="string">&#x27;三级&#x27;</span></span><br><span class="line">            &#125;,</span><br><span class="line">            component: <span class="function">() =&gt;</span> <span class="keyword">import</span>(<span class="string">&#x27;@/view/multilevel/level-2-2/level-2-2-1.vue&#x27;</span>)</span><br><span class="line">          &#125;,</span><br><span class="line">          &#123;</span><br><span class="line">            path: <span class="string">&#x27;level_2_2_2&#x27;</span>,</span><br><span class="line">            name: <span class="string">&#x27;level_2_2_2&#x27;</span>,</span><br><span class="line">            meta: &#123;</span><br><span class="line">              icon: <span class="string">&#x27;md-funnel&#x27;</span>,</span><br><span class="line">              title: <span class="string">&#x27;三级&#x27;</span></span><br><span class="line">            &#125;,</span><br><span class="line">            component: <span class="function">() =&gt;</span> <span class="keyword">import</span>(<span class="string">&#x27;@/view/multilevel/level-2-2/level-2-2-2.vue&#x27;</span>)</span><br><span class="line">          &#125;</span><br><span class="line">        ]</span><br><span class="line">      &#125;,</span><br><span class="line">      &#123;</span><br><span class="line">        path: <span class="string">&#x27;level_2_3&#x27;</span>,</span><br><span class="line">        name: <span class="string">&#x27;level_2_3&#x27;</span>,</span><br><span class="line">        meta: &#123;</span><br><span class="line">          icon: <span class="string">&#x27;md-funnel&#x27;</span>,</span><br><span class="line">          title: <span class="string">&#x27;二级-3&#x27;</span></span><br><span class="line">        &#125;,</span><br><span class="line">        component: <span class="function">() =&gt;</span> <span class="keyword">import</span>(<span class="string">&#x27;@/view/multilevel/level-2-3.vue&#x27;</span>)</span><br><span class="line">      &#125;</span><br><span class="line">    ]</span><br><span class="line">  &#125;</span><br><span class="line">]</span><br></pre></td></tr></table></figure>



<p>效果示例：</p>
<p><img src="/2021/04/14/vue-admin-pro-02/20210412212513.png" alt="多级菜单-效果示例"></p>

    </div>

    
    
    
        <div class="reward-container">
  <div></div>
  <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/images/wechatpay.jpg" alt="Erwin Feng 微信支付">
        <p>微信支付</p>
      </div>
      
      <div style="display: inline-block;">
        <img src="/images/alipay.jpg" alt="Erwin Feng 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item" align="center">
          <img src="/images/qrcode_wx_public_fengwenyi.jpg" height="150">
          <span class="label">微信公众号</span>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/vue-js/" rel="tag"># vue.js</a>
              <a href="/tags/vue-admin-pro/" rel="tag"># vue-admin-pro</a>
              <a href="/tags/View-UI/" rel="tag"># View UI</a>
              <a href="/tags/iview-admin/" rel="tag"># iview-admin</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/04/14/vue-admin-pro-01/" rel="prev" title="后端管理系统开发（一）：登录篇">
      <i class="fa fa-chevron-left"></i> 后端管理系统开发（一）：登录篇
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/04/19/springcloud-alibaba-02-version/" rel="next" title="Spring Cloud Alibaba（二）：版本对应关系">
      Spring Cloud Alibaba（二）：版本对应关系 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E5%9F%BA%E7%A1%80"><span class="nav-number">1.</span> <span class="nav-text">1 基础</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E8%B7%AF%E7%94%B1"><span class="nav-number">1.1.</span> <span class="nav-text">1.1 路由</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-router-push"><span class="nav-number">1.2.</span> <span class="nav-text">1.2 router.push</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-3-router-go-n"><span class="nav-number">1.3.</span> <span class="nav-text">1.3 router.go(n)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-4-%E5%91%BD%E5%90%8D%E8%B7%AF%E7%94%B1"><span class="nav-number">1.4.</span> <span class="nav-text">1.4 命名路由</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-5-%E9%87%8D%E5%AE%9A%E5%90%91"><span class="nav-number">1.5.</span> <span class="nav-text">1.5 重定向</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-6-%E8%B7%AF%E7%94%B1%E4%BC%A0%E5%8F%82"><span class="nav-number">1.6.</span> <span class="nav-text">1.6 路由传参</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-6-1-%E9%80%9A%E8%BF%87path%E4%BC%A0%E5%8F%82"><span class="nav-number">1.6.1.</span> <span class="nav-text">1.6.1 通过path传参</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-6-2-%E9%80%9A%E8%BF%87params%E4%BC%A0%E5%8F%82"><span class="nav-number">1.6.2.</span> <span class="nav-text">1.6.2 通过params传参</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-6-3-%E9%80%9A%E8%BF%87query%E4%BC%A0%E5%8F%82"><span class="nav-number">1.6.3.</span> <span class="nav-text">1.6.3 通过query传参</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-7-%E5%AE%8C%E6%95%B4%E5%AF%BC%E8%88%AA%E8%A7%A3%E6%9E%90%E6%B5%81%E7%A8%8B"><span class="nav-number">1.7.</span> <span class="nav-text">1.7 完整导航解析流程</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84"><span class="nav-number">2.</span> <span class="nav-text">2 目录结构</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E6%A0%87%E7%AD%BE"><span class="nav-number">3.</span> <span class="nav-text">3 标签</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#path"><span class="nav-number">3.1.</span> <span class="nav-text">path</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#name"><span class="nav-number">3.2.</span> <span class="nav-text">name</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#meta"><span class="nav-number">3.3.</span> <span class="nav-text">meta</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#title"><span class="nav-number">3.4.</span> <span class="nav-text">title</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#hideInMenu"><span class="nav-number">3.5.</span> <span class="nav-text">hideInMenu</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#component"><span class="nav-number">3.6.</span> <span class="nav-text">component</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#notCache"><span class="nav-number">3.7.</span> <span class="nav-text">notCache</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#icon"><span class="nav-number">3.8.</span> <span class="nav-text">icon</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#hideInBread"><span class="nav-number">3.9.</span> <span class="nav-text">hideInBread</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#redirect"><span class="nav-number">3.10.</span> <span class="nav-text">redirect</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E5%9B%BE%E6%A0%87"><span class="nav-number">4.</span> <span class="nav-text">4 图标</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-%E5%A4%9A%E8%AF%AD%E8%A8%80"><span class="nav-number">5.</span> <span class="nav-text">5 多语言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-%E5%8D%95%E7%8B%AC%E9%A1%B5"><span class="nav-number">6.</span> <span class="nav-text">6 单独页</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#7-%E4%B8%80%E7%BA%A7%E8%8F%9C%E5%8D%95"><span class="nav-number">7.</span> <span class="nav-text">7 一级菜单</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#8-%E4%BA%8C%E7%BA%A7%E8%8F%9C%E5%8D%95"><span class="nav-number">8.</span> <span class="nav-text">8 二级菜单</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#9-%E5%A4%9A%E7%BA%A7%E8%8F%9C%E5%8D%95"><span class="nav-number">9.</span> <span class="nav-text">9 多级菜单</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Erwin Feng"
      src="https://portrait.gitee.com/uploads/avatars/user/382/1147388_fengwenyi_1589149473.png">
  <p class="site-author-name" itemprop="name">Erwin Feng</p>
  <div class="site-description" itemprop="description">我是冯文议，软件开发工程师，专注于程序设计与开发。开源项目：JavaLib、api-result。喜欢看电影、听音乐、自驾游。</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">7</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">12</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/fengwenyi" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;fengwenyi" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://gitee.com/fengwenyi" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;fengwenyi" rel="noopener" target="_blank"><i class="fab fa-git fa-fw"></i>Gitee</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">蜀ICP备17004656号 </a>
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Erwin Feng</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : true,
      notify     : true,
      appId      : 'TmVgfqdEKDu3mW6CCqoopJzc-gzGzoHsz',
      appKey     : 'nLPReImvGVaHrUVM3r7OqJh8',
      placeholder: "说点什么",
      avatar     : 'mp',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-cn' || 'zh-cn',
      path       : location.pathname,
      recordIP   : true,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
